/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Service;

import DataManager.MySQLCommonDataProvider;
import DataManager.VCoreUserDataProvider;
import java.util.regex.*;

/**
 *
 * @author nguyendn
 */
public class UserObj {
    public int userid = 0;
    public String username="";
    //public String password;
    public char is_active;
    public int money;
    public String fullname = "";
    public String address = "";
    public int birth_year = 0;
    public byte gender;
    public byte hair;
    public String cmnd = "";
    public String mobile = "";
    public int city = 0;
    public int avatar;
    public int nickColor;
    public String emotion_status = "";
    public int user_level = 0;
    public int user_type = 0;
    public String SMS_reg_provider = "";

    public boolean checkUsernameExists(String username) {
        boolean res = true;
        if (!VCoreUserDataProvider.getInstance().CheckUsernameExists(username)){
             res =  false;
         }
        return res;
    }

    public boolean validateEmail(String email) {
        String regEx = "\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}\\b";
        Pattern p = Pattern.compile(regEx);
        Matcher m = p.matcher(email);
        if (m.find()) {
            return true;
        } else {
            return false;
        }
    }

    public boolean isVIPAccount() {        
        return user_type == 2; // VIP account type
    }

    public boolean isActivated() {
        return ((is_active == 'Y') || (is_active == 'L')); // activated
    }

    public boolean isDisabled() {
        return ((is_active == 'D')); // disable by admin
    }

    public boolean isLocked() {
        return ((is_active == 'L')); // locked by user
    }
}
